package ru.myrtle.umf.impl;

import java.util.*;
import ru.myrtle.umf.*;
import ru.myrtle.umf.util.*;

public class UReferenceImpl extends UObjectImpl implements UReference {

    protected static final boolean CONTAINMENT_DEFAULT = Boolean.FALSE;
    protected static final boolean TRANSIENT_DEFAULT = Boolean.FALSE;
    protected static final boolean VOLATILE_DEFAULT = Boolean.FALSE;
    protected static final boolean CHANGEABLE_DEFAULT = Boolean.FALSE;
    protected static final boolean DERIVED_DEFAULT = Boolean.FALSE;
    protected static final String NAME_DEFAULT = null;
    protected static final String DESCRIPTION_DEFAULT = null;
    protected static final boolean MANY_DEFAULT = Boolean.FALSE;
    protected static final boolean ORDERED_DEFAULT = Boolean.FALSE;
    protected static final boolean UNIQUE_DEFAULT = Boolean.FALSE;

    public UReferenceImpl() {
    }

    @Override
    public UClass uClass() {
        return UModel.UREFERENCE;
    }
    
    private UClass _type_;

    @Override
    public final UClass getType() {
        return _type_;
    }

    @Override
    public final boolean isSetType() {
        return _type_ != null;
    }

    private void setTypeImpl(UClass _type_) {
        this._type_ = _type_;
    }

    @Override
    public final void setType(UClass _type_) {
        if (this._type_ != _type_) {
                                                                    setTypeImpl(_type_);
                                                                }
    }
    
    @Override
    public final void unsetType() {
        setTypeImpl(null);
    }

    private boolean _containment_ = CONTAINMENT_DEFAULT;

    @Override
    public final boolean isContainment() {
        return _containment_;
    }

    @Override
    public final boolean isSetContainment() {
        return _containment_ != CONTAINMENT_DEFAULT;
    }

    @Override
    public final void setContainment(boolean _containment_) {
        this._containment_ = _containment_;
    }

    @Override
    public final void unsetContainment() {
        _containment_ = CONTAINMENT_DEFAULT;
    }

    private UReference _opposite_;

    @Override
    public final UReference getOpposite() {
        return _opposite_;
    }

    @Override
    public final boolean isSetOpposite() {
        return _opposite_ != null;
    }

    private void setOppositeImpl(UReference _opposite_) {
        this._opposite_ = _opposite_;
    }

    @Override
    public final void setOpposite(UReference _opposite_) {
        if (this._opposite_ != _opposite_) {
                                                                    setOppositeImpl(_opposite_);
                                                                }
    }
    
    @Override
    public final void unsetOpposite() {
        setOppositeImpl(null);
    }

    private boolean _transient_ = TRANSIENT_DEFAULT;

    @Override
    public final boolean isTransient() {
        return _transient_;
    }

    @Override
    public final boolean isSetTransient() {
        return _transient_ != TRANSIENT_DEFAULT;
    }

    @Override
    public final void setTransient(boolean _transient_) {
        this._transient_ = _transient_;
    }

    @Override
    public final void unsetTransient() {
        _transient_ = TRANSIENT_DEFAULT;
    }

    private boolean _volatile_ = VOLATILE_DEFAULT;

    @Override
    public final boolean isVolatile() {
        return _volatile_;
    }

    @Override
    public final boolean isSetVolatile() {
        return _volatile_ != VOLATILE_DEFAULT;
    }

    @Override
    public final void setVolatile(boolean _volatile_) {
        this._volatile_ = _volatile_;
    }

    @Override
    public final void unsetVolatile() {
        _volatile_ = VOLATILE_DEFAULT;
    }

    private boolean _changeable_ = CHANGEABLE_DEFAULT;

    @Override
    public final boolean isChangeable() {
        return _changeable_;
    }

    @Override
    public final boolean isSetChangeable() {
        return _changeable_ != CHANGEABLE_DEFAULT;
    }

    @Override
    public final void setChangeable(boolean _changeable_) {
        this._changeable_ = _changeable_;
    }

    @Override
    public final void unsetChangeable() {
        _changeable_ = CHANGEABLE_DEFAULT;
    }

    private boolean _derived_ = DERIVED_DEFAULT;

    @Override
    public final boolean isDerived() {
        return _derived_;
    }

    @Override
    public final boolean isSetDerived() {
        return _derived_ != DERIVED_DEFAULT;
    }

    @Override
    public final void setDerived(boolean _derived_) {
        this._derived_ = _derived_;
    }

    @Override
    public final void unsetDerived() {
        _derived_ = DERIVED_DEFAULT;
    }

    private UClass _containingClass_;

    @Override
    public final UClass getContainingClass() {
        return _containingClass_;
    }

    @Override
    public final boolean isSetContainingClass() {
        return _containingClass_ != null;
    }

    private void setContainingClassImpl(UClass _containingClass_) {
        this._containingClass_ = _containingClass_;
    }

    private String _name_ = NAME_DEFAULT;

    @Override
    public final String getName() {
        return _name_;
    }

    @Override
    public final boolean isSetName() {
        return _name_ != NAME_DEFAULT;
    }

    @Override
    public final void setName(String _name_) {
        this._name_ = _name_;
    }

    @Override
    public final void unsetName() {
        _name_ = NAME_DEFAULT;
    }

    private String _description_ = DESCRIPTION_DEFAULT;

    @Override
    public final String getDescription() {
        return _description_;
    }

    @Override
    public final boolean isSetDescription() {
        return _description_ != DESCRIPTION_DEFAULT;
    }

    @Override
    public final void setDescription(String _description_) {
        this._description_ = _description_;
    }

    @Override
    public final void unsetDescription() {
        _description_ = DESCRIPTION_DEFAULT;
    }

    private UList<UAnnotation> _annotations_;

    @Override
    public final UList<UAnnotation> getAnnotations() {
        if (_annotations_ == null) {
            _annotations_ = new UObjectContainmentList<UAnnotation>(this, UModel.UELEMENT__ANNOTATIONS);
        }
        return _annotations_;
    }

    @Override
    public final boolean isSetAnnotations() {
        return _annotations_ != null && !_annotations_.isEmpty();
    }

    @Override
    public void setAnnotations(UList<UAnnotation> _annotations_) {
        getAnnotations().clear();
        getAnnotations().addAll(_annotations_);
    }

    @Override
    public void unsetAnnotations() {
        if (_annotations_ != null) {
            _annotations_.clear();
        }
    }

    private boolean _many_ = MANY_DEFAULT;

    @Override
    public final boolean isMany() {
        return _many_;
    }

    @Override
    public final boolean isSetMany() {
        return _many_ != MANY_DEFAULT;
    }

    @Override
    public final void setMany(boolean _many_) {
        this._many_ = _many_;
    }

    @Override
    public final void unsetMany() {
        _many_ = MANY_DEFAULT;
    }

    private boolean _ordered_ = ORDERED_DEFAULT;

    @Override
    public final boolean isOrdered() {
        return _ordered_;
    }

    @Override
    public final boolean isSetOrdered() {
        return _ordered_ != ORDERED_DEFAULT;
    }

    @Override
    public final void setOrdered(boolean _ordered_) {
        this._ordered_ = _ordered_;
    }

    @Override
    public final void unsetOrdered() {
        _ordered_ = ORDERED_DEFAULT;
    }

    private boolean _unique_ = UNIQUE_DEFAULT;

    @Override
    public final boolean isUnique() {
        return _unique_;
    }

    @Override
    public final boolean isSetUnique() {
        return _unique_ != UNIQUE_DEFAULT;
    }

    @Override
    public final void setUnique(boolean _unique_) {
        this._unique_ = _unique_;
    }

    @Override
    public final void unsetUnique() {
        _unique_ = UNIQUE_DEFAULT;
    }


    @Override
    @SuppressWarnings(
        "unchecked"
    )
    public Object uGet(UFeature feature) {
        if (feature == UModel.UREFERENCE__TYPE) {
            return getType();
        }
        if (feature == UModel.UREFERENCE__CONTAINMENT) {
            return isContainment();
        }
        if (feature == UModel.UREFERENCE__OPPOSITE) {
            return getOpposite();
        }
        if (feature == UModel.UFEATURE__TRANSIENT) {
            return isTransient();
        }
        if (feature == UModel.UFEATURE__VOLATILE) {
            return isVolatile();
        }
        if (feature == UModel.UFEATURE__CHANGEABLE) {
            return isChangeable();
        }
        if (feature == UModel.UFEATURE__DERIVED) {
            return isDerived();
        }
        if (feature == UModel.UFEATURE__CONTAINING_CLASS) {
            return getContainingClass();
        }
        if (feature == UModel.UELEMENT__NAME) {
            return getName();
        }
        if (feature == UModel.UELEMENT__DESCRIPTION) {
            return getDescription();
        }
        if (feature == UModel.UELEMENT__ANNOTATIONS) {
            return getAnnotations();
        }
        if (feature == UModel.UMULTIPLICITY__MANY) {
            return isMany();
        }
        if (feature == UModel.UMULTIPLICITY__ORDERED) {
            return isOrdered();
        }
        if (feature == UModel.UMULTIPLICITY__UNIQUE) {
            return isUnique();
        }

        return super.uGet(feature);
    }

    @Override
    @SuppressWarnings(
        "unchecked"
    )
    public boolean uIsSet(UFeature feature) {
        if (feature == UModel.UREFERENCE__TYPE) {
            return isSetType();
        }
        if (feature == UModel.UREFERENCE__CONTAINMENT) {
            return isSetContainment();
        }
        if (feature == UModel.UREFERENCE__OPPOSITE) {
            return isSetOpposite();
        }
        if (feature == UModel.UFEATURE__TRANSIENT) {
            return isSetTransient();
        }
        if (feature == UModel.UFEATURE__VOLATILE) {
            return isSetVolatile();
        }
        if (feature == UModel.UFEATURE__CHANGEABLE) {
            return isSetChangeable();
        }
        if (feature == UModel.UFEATURE__DERIVED) {
            return isSetDerived();
        }
        if (feature == UModel.UFEATURE__CONTAINING_CLASS) {
            return isSetContainingClass();
        }
        if (feature == UModel.UELEMENT__NAME) {
            return isSetName();
        }
        if (feature == UModel.UELEMENT__DESCRIPTION) {
            return isSetDescription();
        }
        if (feature == UModel.UELEMENT__ANNOTATIONS) {
            return isSetAnnotations();
        }
        if (feature == UModel.UMULTIPLICITY__MANY) {
            return isSetMany();
        }
        if (feature == UModel.UMULTIPLICITY__ORDERED) {
            return isSetOrdered();
        }
        if (feature == UModel.UMULTIPLICITY__UNIQUE) {
            return isSetUnique();
        }

        return super.uIsSet(feature);
    }

    @Override
    @SuppressWarnings(
        "unchecked"
    )
    public void uSet(UFeature feature, Object value) {
        if (feature == UModel.UREFERENCE__TYPE) {
            setType((UClass) value);
            return;
        }
        if (feature == UModel.UREFERENCE__CONTAINMENT) {
            setContainment(((Boolean) value).booleanValue());
            return;
        }
        if (feature == UModel.UREFERENCE__OPPOSITE) {
            setOpposite((UReference) value);
            return;
        }
        if (feature == UModel.UFEATURE__TRANSIENT) {
            setTransient(((Boolean) value).booleanValue());
            return;
        }
        if (feature == UModel.UFEATURE__VOLATILE) {
            setVolatile(((Boolean) value).booleanValue());
            return;
        }
        if (feature == UModel.UFEATURE__CHANGEABLE) {
            setChangeable(((Boolean) value).booleanValue());
            return;
        }
        if (feature == UModel.UFEATURE__DERIVED) {
            setDerived(((Boolean) value).booleanValue());
            return;
        }
        if (feature == UModel.UELEMENT__NAME) {
            setName((String) value);
            return;
        }
        if (feature == UModel.UELEMENT__DESCRIPTION) {
            setDescription((String) value);
            return;
        }
        if (feature == UModel.UELEMENT__ANNOTATIONS) {
            setAnnotations((UList<UAnnotation>) value);
            return;
        }
        if (feature == UModel.UMULTIPLICITY__MANY) {
            setMany(((Boolean) value).booleanValue());
            return;
        }
        if (feature == UModel.UMULTIPLICITY__ORDERED) {
            setOrdered(((Boolean) value).booleanValue());
            return;
        }
        if (feature == UModel.UMULTIPLICITY__UNIQUE) {
            setUnique(((Boolean) value).booleanValue());
            return;
        }

        super.uSet(feature, value);
    }

    @Override
    @SuppressWarnings(
        "unchecked"
    )
    public void uUnset(UFeature feature) {
        if (feature == UModel.UREFERENCE__TYPE) {
            unsetType();
            return;
        }
        if (feature == UModel.UREFERENCE__CONTAINMENT) {
            unsetContainment();
            return;
        }
        if (feature == UModel.UREFERENCE__OPPOSITE) {
            unsetOpposite();
            return;
        }
        if (feature == UModel.UFEATURE__TRANSIENT) {
            unsetTransient();
            return;
        }
        if (feature == UModel.UFEATURE__VOLATILE) {
            unsetVolatile();
            return;
        }
        if (feature == UModel.UFEATURE__CHANGEABLE) {
            unsetChangeable();
            return;
        }
        if (feature == UModel.UFEATURE__DERIVED) {
            unsetDerived();
            return;
        }
        if (feature == UModel.UELEMENT__NAME) {
            unsetName();
            return;
        }
        if (feature == UModel.UELEMENT__DESCRIPTION) {
            unsetDescription();
            return;
        }
        if (feature == UModel.UELEMENT__ANNOTATIONS) {
            unsetAnnotations();
            return;
        }
        if (feature == UModel.UMULTIPLICITY__MANY) {
            unsetMany();
            return;
        }
        if (feature == UModel.UMULTIPLICITY__ORDERED) {
            unsetOrdered();
            return;
        }
        if (feature == UModel.UMULTIPLICITY__UNIQUE) {
            unsetUnique();
            return;
        }

        super.uUnset(feature);
    }


    @Override
    @SuppressWarnings(
        "unchecked"
    )
    public void uInternalInverseAdd(UObject otherEnd, UReference reference) {
        if (reference == UModel.UFEATURE__CONTAINING_CLASS) {
            setContainingClassImpl((UClass) otherEnd);
            return;
        }
    }

    @Override
    @SuppressWarnings(
        "unchecked"
    )
    public void uInternalInverseRemove(UObject otherEnd, UReference reference) {
        if (reference == UModel.UFEATURE__CONTAINING_CLASS) {
            setContainingClassImpl(null);
            return;
        }
    }


    @Override
    public String toString() {
        StringBuffer result = new StringBuffer();

        result.append("UReference");
        result.append(" (");
        result.append("containment: ");
        result.append(_containment_);
        result.append(", ");
        result.append("transient: ");
        result.append(_transient_);
        result.append(", ");
        result.append("volatile: ");
        result.append(_volatile_);
        result.append(", ");
        result.append("changeable: ");
        result.append(_changeable_);
        result.append(", ");
        result.append("derived: ");
        result.append(_derived_);
        result.append(", ");
        result.append("name: ");
        result.append(_name_);
        result.append(", ");
        result.append("description: ");
        result.append(_description_);
        result.append(", ");
        result.append("many: ");
        result.append(_many_);
        result.append(", ");
        result.append("ordered: ");
        result.append(_ordered_);
        result.append(", ");
        result.append("unique: ");
        result.append(_unique_);
        result.append(')');

        return result.toString();
    }
}




